// pages/car/car.js
import {
  getCartByUserIdAPI
} from '../../api/cart'

Page({
  data: {
    cartList: [],
    userId: 0,
    currentCheck: [],
    checkValue: []
  },
  onLoad(options) {
    let user = wx.getStorageSync('user')
    if (!user) {
      wx.navigateTo({
        url: '/pages/login/login'
      });
    }
    this.userId = user.id
    this.getCartByUserId(user.id)
  },
  onShow() {
    this.onLoad()
  },
  onChangeCheckBox(event) {
    console.log('group', event.detail.value);
    this.setData({
      currentCheck: event.detail.value,
    });
  },

  async getCartByUserId(id) {
    const {
      result
    } = await getCartByUserIdAPI(id);
    this.setData({
      cartList: result,
    })
  },
  onDelete() {

  },
  onPay() {

  },
})